#include "TROOT.h"
#include "TRint.h"
#include <iostream>
#include <fstream>
#include "TCanvas.h"
#include "TH2.h"
#include "TStyle.h"
#include "TText.h"


using namespace std;

char sourcefile[256], targetfile[256];
char title[256];
char yaxis[256];

void drawHs() {

  Float_t xx, yy;

  ifstream in;
  in.open(sourcefile);
  
  TCanvas *tc = new TCanvas("", "", 600, 400); 
  tc->Divide(1); 
  tc->cd(1); 
 
  
  TH2F *myhist = new TH2F(title, title, 2000, 0, 16, 2000, 0, 1);
  gStyle->SetOptStat(0);
  gStyle->SetLabelSize(0.05,"XY");
  gStyle->SetTextSize(15);
  
  myhist->SetXTitle("# Threads");
  // myhist->SetYTitle(yaxis);
  myhist->SetBit(TH2::kCanRebin);
  myhist->SetMarkerStyle(2);
  myhist->SetMarkerColor(6);
  myhist->SetMarkerSize(2);

  while (1) {
      in >> xx >> yy;
      if (!in.good()) break;
      myhist->Fill(xx,yy);
  }

  in.close();
  myhist->Draw();
  tc->Print(targetfile);
}

main(int argc, char* argv[])
{
  if ( argc < 4 ) return 0;
  strcpy(sourcefile, argv[1]);
  strcpy(targetfile, argv[2]);
  strcpy(title,    argv[3]);
  drawHs();
}
